home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 3.iso
/
relnotes
/
shared
/
howto.data
< prev
next >
Wrap
Text File
|
2002-10-07
|
10KB
|
274 lines
<!-- -*- HTML -*- -->
<!-- INCLUDE SIDENAV -->
<!-- NO HIGHLIGHTS -->
<!-- BEGIN TITLE -->
<TITLE>Notes on building Open Source software on IRIX</TITLE>
<META NAME="keywords" CONTENT="SGI IRIX Open Source freeware">
<META NAME="description" CONTENT="Freeware pre-configured, pre-compiled, and inst packaged for SGI IRIX 6.5">
<META NAME="owner" CONTENT="freeware@sgi.com">
<!-- END TITLE -->
<!-- BEGIN CONTENTS -->
<h2>Notes on building Open Source software on IRIX</h2>
<p>
This is a draft document to help people build open source software on
IRIX. It may be missing some items but having built literally
hundreds of packages on IRIX over the years we're pretty confident
that most of the pitfalls are covered.
<br>
<h3>General</h3>
IRIX has a very comprehensive Unix API. Not only it is POSIX
and POSIX-2 compliant, it is also compliant with XOPEN XPG/4,
SVID (SystemV R4), BSD extensions, Unix 95 (Spec 1170) and more.
<p>
Software that compiles on other UNIX'es (notably those
with a smaller API, like Linux and Free/Open/Net BSD),
should, almost with no exceptions, compile and run smoothly
on IRIX. But read on...
<p>
Still there's way too much software out there that makes non-portable
assumptions or is written improperly, which may cause problems.
<br>
<h3>Here's an item list to save you time porting
open source software to IRIX.</h3>
<ul>
<li><a href="#a0">GNU configure and autoconf</a>
<li><a href="#a1">Makefiles</a>
<li><a href="#a2">ranlib</a>
<li><a href="#a3">install</a>
<li><a href="#a4">BSD</a>
<li><a href="#a5">System types</a>
<li><a href="#a6">varargs</a>
<li><a href="#a7">Catching other problems</a>
<li><a href="#a8">SGI cc</a>
<li><a href="#a9">Multiple other problems (too many to list here)</a>
<li><a href="#b0">Build vs. target env</a>
<li><a href="#b1">gcc vs. cc</a>
<li><a href="#b2">portable types</a>
</ul>
<br>
<hr noshade align="center" width="70%">
<br>
<br>
<ul>
<p>
<li><b><a name="a0">GNU configure and autoconf</a></b>
<p>
GNU autoconf generates configure scripts that assume that if a
library exists, it should be used. This is incorrect on IRIX, which
keeps some old libraries around just for the sake of backward
compatibility with very old programs. This alone breaks most of the
GNU utilities on IRIX. To prevent this from happening, simply force
GNU configure to explicitly ignore '<code>libsocket</code>',
'<code>libnsl</code>', '<code>libgen</code>' and '<code>libsun</code>'.
All these interfaces have their up-to-date entries in the standard C
library <code>libc.so</code> on IRIX 6.x.
<p>
For example, when calling GNU configure you should use something like:
<pre>
ac_cv_lib_gen_getmntent=no \
ac_cv_lib_sun=no \
ac_cv_lib_sun_getpwnam=no \
ac_cv_lib_sun_getmntent=no \
ac_cv_lib_sun_yp_match=no \
ac_cv_lib_socket=no \
ac_cv_lib_socket_main=no \
configure ...
</pre>
Note that this is just an example. Make sure to look at your
<code>config.cache</code> (or equivalent) file after configuration,
and inspect it for any suspicious <code>ac_cv_lib...</code> entries
that match one of the libraries mentioned above and force them to
<code>no</code> (or equivalent).
</ul>
<p>
<ul>
<li><b><a name="a1">Makefiles</a></b>
<p>
Some open source programs assume GNU make in their Makefiles. You
should probably use GNU make on IRIX too. Compatibility is good.
With GNU make supporting parallel makes there's really no reason to
use any IRIX specific make like <code>smake</code>,
<code>pmake</code>, or <code>make</code>.
<p>
If you don't have GNU make for IRIX you can download it from <a
href="http://freeware.sgi.com/">http://freeware.sgi.com/</a> and
not worry about Makefile portability anymore.
<p>
<li><b><a name="a2">ranlib</a></b>
<p>
This is a historical BSD thing that should have been done
transparently by the linker. You don't need to run
<code>ranlib</code> in IRIX. If your Makefile calls
<code>ranlib</code> either delete this or define it to a no-op.
<pre>
gmake RANLIB=: ...
</pre>
<p>
<li><b><a name="a3">install</a></b>
<p>
The Berkeley '<code>install</code>' is incompatible with the SYSV version.
Either upgrade to IRIX 6.5 (where the IRIX install has transparent
BSD compatibility) or define:<pre>
gmake INSTALL=bsdinst ...</pre>
<p>
<li><b><a name="a4">BSD</a></b>
<p>
BSD programs that assume a BSD environment should compile
on IRIX without change (at least in 95% of cases)
by forcing BSD compatibility via CFLAGS, e.g:<pre>
gmake CFLAGS="-D_BSD_COMPAT ..."</pre>
<p>
If you don't want <b><i>full</i></b> BSD compatibility,
consider using one or more of:<pre>
-D_BSD_TYPES
-D_BSD_TIME
-D_BSD_SIGNALS
</pre>
<b>Important:</b> if your software is more "properly" written and
uses POSIX signals (i.e. <code>sigaction</code> instead of
<code>signal</code>) then you <b>must not</b> compile with
<code>-D_BSD_SIGNALS</code>. Mixing signal models may cause
unpredictable problems.
<p>
<li><b><a name="a5">System types</a></b>
<p>
Some programs assume system types, in particular
'<code>off_t</code>', are 32 bit (i.e. that files don't exceed 4GB in size)
These programs are making bad assumptions, but this problem can be
overcome by compiling in the o32 (cc -32) ABI:<pre>
gmake CC="cc -32 ..."
</pre>
<p>
<li><b><a name="a6">varargs</a></b>
<p>
Some programs do not comply with the ANSI varargs syntax and conventions
(i.e. include <code><stdarg.h></code> and use ellipsis
in the argument list)
Again, if those don't work they may start working by compiling
using the o32 ABI:<pre>
gmake CC="cc -32 ..."
</pre>
<p>
<li><b><a name="a7">Catching other problems</a></b>
<p>
The SGI <b>cc</b> is verbose and pedantic. The problem is that when
you get way too many warnings you start ignoring the real ones.
<p>
To make the SGI compiler more like gcc in terms of warnings you may use
something like:<pre>
NOWARN = -woff 1009,1014,1110,1116,1185,1188,1204,1230,1233 \
-Wl,-woff,85,-woff,84
$(CC) $(NOWARN) ...</pre>
In your Makefiles
<p>
<li><b><a name="a8">SGI cc</a></b>
<p>
While the SGI cc may look too pedantic, it can catch a lot
of real source code bugs. Consider compiling with:<pre>
CC="cc -fullwarn ..."
</pre>
<p>
and really clean your source of type mismatches.
<p>
<li><b><a name="a9">Multiple other problems (too many to list here)</a></b>
<p>
Over the years IRIX got thousands of bug fixes. As expected, problems
on IRIX 4.0.x are much more numerous than problems on IRIX 6.5.
If you can upgrade, please do. <i>Life is way easier with IRIX 6.5.</i>
<p>
<li><b><a name="b0">Build vs. target env</a></b>
<p>
Virtually all open source packages assume that the building environment
is the same as the target environment. In fact every Makefile with
a '<code>make install</code>' that directly installs into system directories
probably makes this assumption. IRIX supports a much more elegant
model of 'inst'able packages that can be built anywhere and
installed anywhere else.
<p>
It would be nice if there was a UNIX-wide standard for this. Red Hat
RPM and other Linux installers are getting there, which is great.
<p>
We usually build open source software with an IRIX 6.5 ROOT
(i.e. get include files and libraries from a backward compatible
6.5 mounted directory). Assuming this directory is called
<code>/6.5_root</code> this can be done by:<pre>
cc -nostdinc -I. -I/6.5_root/usr/include ... (compiling)
cc -nostdlib -L/6.5_root/usr/lib32 ... (linking)
</pre>
<p>
The packaging itself is an art form. At SGI we use a specialized
'<code>install</code>' perl script to intercept calls from
'<code>make install'</code>. This install adds the appropriate
lines to the '<code>idb</code>' file instead of actually installing
files. Later, this idb file is used by '<code>gendist</code>' to
create the packages. Unfortunately, far too many open source
packages call <code>mv</code>, <code>cp</code>, <code>tar</code>,
etc. to install, so they bypass this mechanism. We have considered
but not yet implemented other solutions, such as trapping system
calls or running in a <code>chroot</code> directory. If you find
(or implement!) a better solution please let us know.
<p>
<li><b><a name="b1">gcc vs. cc</a></b>
<p>
Code that runs fine when compiled with SGI cc and doesn't run
when compiled with gcc might be calling one of the following functions:<pre>
inet_ntoa, inet_lnaof, inet_netof, inet_makeaddr, semctl
</pre>
<p>
(there may be others). These are functions that get passed
or return structs that are smaller than 16 bytes but not 8 bytes long.
<i>gcc</i> and <i>SGI cc</i> are incompatible in the way they pass
these structs so compiling with gcc and linking with the SGI
<code>libc.so</code> (which was compiled with the <i>SGI cc</i>)
is likely to cause these problems.
Note that this problem is pretty rare since such functions are
not widely used. This may be considered a bug in <i>gcc</i> but is too
involved to fix I'm told.
<p>
<li><b><a name="b2">portable types</a></b>
<p>
Occasionally code that works on other platforms will compile fine on
IRIX, but will misbehave when run. These problems can be difficult
to track down, but one thing to check for is assumptions about
whether <code>char</code> is signed or unsigned. IRIX compilers
default to unsigned -- if it matters your code should be explicit!
<p>
Setting up parallel debugging sessions and stepping through the
working and non-working code simultaneously to find where they
diverge is often helpful.
</ul>
<center>
<hr noshade width="80%">
Additions and contributions to this list will be gratefully accepted.
<br>
<a href="mailto:freeware@sgi.com">freeware@sgi.com</a>
<hr noshade width="80%">
</center>
<!-- END CONTENTS -->